import 'package:FiduMart/generated/json/base/json_convert_content.dart';
import 'package:FiduMart/core/network/model/login_entity.dart';

LoginEntity $LoginEntityFromJson(Map<String, dynamic> json) {
  final LoginEntity loginEntity = LoginEntity();
  final String? email = jsonConvert.convert<String>(json['email']);
  if (email != null) {
    loginEntity.email = email;
  }
  final String? avatar = jsonConvert.convert<String>(json['avatar']);
  if (avatar != null) {
    loginEntity.avatar = avatar;
  }
  final String? nickName = jsonConvert.convert<String>(json['nickName']);
  if (nickName != null) {
    loginEntity.nickName = nickName;
  }
  final String? token = jsonConvert.convert<String>(json['token']);
  if (token != null) {
    loginEntity.token = token;
  }
  final int? newGift = jsonConvert.convert<int>(json['newGift']);
  if (newGift != null) {
    loginEntity.newGift = newGift;
  }
  final String? guildId = jsonConvert.convert<String>(json['guildId']);
  if (guildId != null) {
    loginEntity.guildId = guildId;
  }
  return loginEntity;
}

Map<String, dynamic> $LoginEntityToJson(LoginEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['email'] = entity.email;
  data['avatar'] = entity.avatar;
  data['nickName'] = entity.nickName;
  data['token'] = entity.token;
  data['newGift'] = entity.newGift;
  data['guildId'] = entity.guildId;
  return data;
}

extension LoginEntityExt on LoginEntity {
  LoginEntity copyWith({
    String? email,
    String? avatar,
    String? nickName,
    String? token,
    int? newGift,
    String? guildId,
  }) {
    return LoginEntity()
      ..email = email ?? this.email
      ..avatar = avatar ?? this.avatar
      ..nickName = nickName ?? this.nickName
      ..token = token ?? this.token
      ..newGift = newGift ?? this.newGift
      ..guildId = guildId ?? this.guildId;
  }
}